package net.huashitong.ssydt.provider.money.service;


import net.huashitong.ssydt.PaginationResult;
import net.huashitong.ssydt.money.entity.SsMoneyVipRecord;
import net.huashitong.ssydt.money.entity.vo.SsMoneyVipRecordQueryInVO;
import net.huashitong.ssydt.provider.money.mapper.SsMoneyVipRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.08.16
 */
@Service
@Transactional
public class SsMoneyVipRecordServiceImpl implements SsMoneyVipRecordService {

    private SsMoneyVipRecordMapper mapper;

    @Autowired
    public SsMoneyVipRecordServiceImpl(SsMoneyVipRecordMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public SsMoneyVipRecord getGmtEndDescByUserId(String userId) {
        return mapper.getGmtEndDescByUserId(userId);
    }

    @Override
    public void save(SsMoneyVipRecord ssMoneyVipRecord) {
        mapper.insert(ssMoneyVipRecord);
    }

	@Override
	public PaginationResult<SsMoneyVipRecord> paginationQuery(SsMoneyVipRecordQueryInVO ssMoneyVipRecordQueryInVO) {
		PaginationResult result = new PaginationResult();
		result.setPageNumber(ssMoneyVipRecordQueryInVO.getPageNumber());
		result.setPageSize(ssMoneyVipRecordQueryInVO.getPageSize());

		// 查询记录总数
		int total = mapper.queryCount(ssMoneyVipRecordQueryInVO);
		result.setPageRecords(total);

		if (total == 0) {
			result.setList(new ArrayList());
		} else {
			// 查询当前页记录
			List<SsMoneyVipRecord> list = mapper.query(ssMoneyVipRecordQueryInVO);
			result.setList(list);
		}
		return result;
	}
}
